<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,height=device-height,inital-scale=1,maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no"/>
    <meta name="format-detection" content="email=no"/>
    <title>信用卡申请</title>
    <link type="text/css" rel="stylesheet" href="css/common.css">
    <link type="text/css" rel="stylesheet" href="css/application.css">
</head>
<body>

<div class="main">
    <div class="banner">
        <img src="image/banner.png">
    </div>
    <div class="step">
        <ul>
            <li><p style="background: #e94a47"><span style="background: #e94a47">1</span></p>
                <p>填写申请人信息</p></li>
            <li><p><span>2</span></p>
                <p>提交信用卡申请</p></li>
            <li><p><span>3</span></p>
                <p>银行审核通知</p></li>
            <div class="clear"></div>
        </ul>
    </div>
    <form>
        <div class="forms">
            <ul>
                <li>请填写申请人信息</li>
                <li><span>姓 &nbsp; 名</span><input id="name" type="text" value="" placeholder="请输入申请人姓名"
                                                  onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')"
                                                  onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))">
                </li>
                <li><span>身份证</span><input id="idCard" type="text" value="" placeholder="请输入申请人身份证"></li>
                <li><span>手机号</span><input id="phone" type="number" value="" placeholder="请输入申请人手机号"></li>
            </ul>
        </div>
        <p style="padding-top: 10px">1.请务必填写申请人真实信息</p>
        <p>2.银行审核通知将直接以短信形式发送到该手机</p>
        <input id="btn" type="button" value="提交资料"/>
    </form>
</div>

</body>
<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script>
    /**
     * 提交申请人信息
     */
    $('#btn').click(function () {
        var id = getQueryString("id");
        var jumpLink = decodeURIComponent(getQueryString("jumpLink"));
        var bankName = getQueryString("bankName");
        var name = $('#name').val();
        var idCard = $('#idCard').val();
        var phone = $('#phone').val();
        if (name === "") {
            alert("请输入申请人姓名")
        }
        else if (idCard === "") {
            alert("请输入身份证");
        }
        else if (!(/^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/.test(idCard))) {
            alert("身份证号有误，请重新输入");
        }
        else if (phone === "") {
            alert("请输入申请人电话")
        }
        else if(!(/^1(3|4|5|7|8)\d{9}$/.test(phone))){
            alert("手机号码有误，请重新输入");
        }
        else {
            $.ajax({
                url: 'https://wallet.seshell.cn/api/apply/business',
                type: 'POST',
                data: {id: id, name: name, phone: phone, idCard: idCard, businessType: 0, bankName: bankName},
                dataType: "json",
                success: function (data) {
                    if(data.data.code === 0){
                        window.location.href = jumpLink
                    }else {
                        alert(data.data.msg)
                    }
                }
            })
        }
    })
</script>
</html>